package com.ruibang.glass.common.utils;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.teaming.cloud.framework2.common.constant.CommonConstant;
import lombok.extern.slf4j.Slf4j;

import java.io.*;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@Slf4j
public class ApproveUserNameUtils {
    public static String getApproveName(String userId, Map<Object, Object> userMap) {
        if (StringUtils.isNotBlank(userId)) {
            if (userId.indexOf(CommonConstant.SpecialSign.COMMA.getName()) != -1) {
                String[] userIds = userId.split(CommonConstant.SpecialSign.COMMA.getName());
                StringBuilder userName = new StringBuilder();
                int size = userIds.length;
                for (int i = 0; i < size; i++) {
                    String name = userMap.get(userIds[i]) == null ? "" : userMap.get(userIds[i]).toString();
                    if (i == size - 1) {
                        userName.append(name);
                    } else {
                        userName.append(name).append(CommonConstant.SpecialSign.COMMA.getName());
                    }
                }
                return userName.toString();
            }
            return userMap.get(userId) == null ? "" : userMap.get(userId).toString();
        }
        return "";
    }


}
